**************************************************************************************************
*** This do file creates the replication results for 
*** Economic Legacy Effects of Armed Conflict: Insights from the Civil War in Aceh, Indonesia  (with Martin Heger), 
*** Conflict Management and Peace Science (forthcoming)
							
**************************************************************************************************
**************************************************************************************************
/* Note: You have to change "local DIR" to the directory you copy the original stata files contained 	*/
/* in the zip file and then run the do file. 
/* You must have Stata version 15 or higher installed													*/
**************************************************************************************************
*/


**************************************************************************************************
/* Note: You have to install the ols_spatial_HAC.ado file in your Stata ado-folder!!!	*/
**************************************************************************************************



drop _all
clear matrix
clear mata



capture net install outreg2, from(http://fmwww.bc.edu/RePEc/bocode/o)			/* checks whether outreg2 is installed 		*/

capture net install xtgraph,  from(http://fmwww.bc.edu/RePEc/bocode/x/)         /* checks whether xtgraph is installed 		*/

***********************************************************************************
local DIR = "d:\Research\Disasters\Heger"  /*change relative path to the directory where the files are located */
cd "`DIR'"
***********************************************************************************


use "Article for CMPS (Aceh).dta", clear



**************************
**** Figure 3 
**************************


* Scatter plot GDP Growth rates against deaths_pop
*** Wartime
twoway (scatter log_gr_annual_99_04 deaths_99_04, mlabel(region) graphregion(color(white)) bgcolor(white) ytitle("GDP growth (percent)") xtitle("Persons killed out of 1000")) /// 
		(lfit log_gr_annual_99_04 deaths_99_04)		 
regress log_gr_annual_99_04 deaths_99_04 if year==2004 , cluster(region2)


**************************
**** Figure 4
**************************

* Scatter plot GDP Growth rates against deaths_pop
*** Peacetime
twoway (scatter log_gr_annual_06_12 deaths_99_04, mlabel(region) graphregion(color(white)) bgcolor(white) ytitle("GDP growth (percent)") xtitle("Persons killed out of 1000")) /// 
		(lfit log_gr_annual_06_12 deaths_99_04)
regress log_gr_annual_06_12 deaths_99_04 if year==2006, cluster(region2)



**************************
**** Figure 5
**************************

* Historical parallel path

use "Article for CMPS (Aceh).dta", clear

preserve

keep if prov==1

drop if region=="Subulussalam" 

replace gdp_round_norm=. if region=="Subulussalam" /*& (year==2003 | year==2004 | year==2005 | year==2006)*/


xtile deaths_2 = deaths_pop if year==2008, nq(2)
replace deaths_2 = 0 if deaths_2 ==.
bysort region: egen deaths_2q = total(deaths_2)
lab def deaths_2q 1 "below median deaths" 2 "above median deaths"

xtgraph gdp_round_norm, group(deaths_2q) av(mean) bar(ci) level(100) 

restore


**************************
**** Figure 6a 
**************************

use "Article for CMPS (Aceh).dta", clear

preserve

keep if year==2005

twoway (scatter buildings_pop deaths_99_04, graphregion(color(white)) bgcolor(white) ytitle("Buildings damaged per 1000 persons") xtitle("Persons killed out of 1000")) /// 
		(lfit buildings_pop deaths_99_04)		 

restore


**************************
**** Figure 6b 
**************************

use "Article for CMPS (Aceh).dta", clear

preserve


keep if year==2005

twoway (scatter buildings_pop nonfatal_99_04, graphregion(color(white)) bgcolor(white) ytitle("Buildings damaged per 1000 persons") xtitle("Non-fatal violence per 1000 persons"))  /// 
		(lfit buildings_pop nonfatal_99_04)		 

restore



**************************
**** Table 1 - baseline
**************************



*** Deaths per pop

use "Article for CMPS (Aceh).dta", clear

tsset


* Generate treatment variables

capture drop    aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608  aceh_treat1_0912 

gen aceh_treat1_0304=deaths_pop
replace aceh_treat1_0304=f.deaths_pop if year==2004
replace aceh_treat1_0304=f2.deaths_pop if year==2003
replace aceh_treat1_0304=0 if year<2003 | year>2004
gen aceh_treat1_05=deaths_pop
replace aceh_treat1_05=0 if year!=2005
gen aceh_treat1_0608=deaths_pop
replace aceh_treat1_0608=0 if year<2006 | year>2008
gen aceh_treat1_0912=deaths_pop
replace aceh_treat1_0912=0 if year<2009

* Set problematic growth data to missing

replace log_gr=. if region=="Subulussalam" & (year==2003 | year==2004 | year==2005 | year==2006)

ols_spatial_HAC log_gr  aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608 aceh_treat1_0912  yy* acehonecc1- acehonecc22   , ///
timevar(year) panelvar(region2) lat(latitude) lon(longitude) distcutoff(100) lagcutoff(10)
outreg2 using table1, excel replace



*** Non-lethal violence per pop

use "Article for CMPS (Aceh).dta", clear

tsset

capture drop    aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608  aceh_treat1_0912 

gen aceh_treat1_0304=nonfatal_pop
replace aceh_treat1_0304=f.nonfatal_pop if year==2004
replace aceh_treat1_0304=f2.nonfatal_pop if year==2003
replace aceh_treat1_0304=0 if year<2003 | year>2004
gen aceh_treat1_05=nonfatal_pop
replace aceh_treat1_05=0 if year!=2005
gen aceh_treat1_0608=nonfatal_pop
replace aceh_treat1_0608=0 if year<2006 | year>2008
gen aceh_treat1_0912=nonfatal_pop
replace aceh_treat1_0912=0 if year<2009

* Set problematic growth data to missing

replace log_gr=. if region=="Subulussalam" & (year==2003 | year==2004 | year==2005 | year==2006)


ols_spatial_HAC log_gr  aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608 aceh_treat1_0912  yy* acehonecc1- acehonecc22   , ///
timevar(year) panelvar(region2) lat(latitude) lon(longitude) distcutoff(100) lagcutoff(10)
outreg2 using table1, excel append





**************************
**** Table 2 - exploring structural change
**************************


**** Tertiary sector growth


*** Deaths per pop


use "Article for CMPS (Aceh).dta", clear

tsset


* Generate treatment variables

capture drop    aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608  aceh_treat1_0912 

gen aceh_treat1_0304=deaths_pop
replace aceh_treat1_0304=f.deaths_pop if year==2004
replace aceh_treat1_0304=f2.deaths_pop if year==2003
replace aceh_treat1_0304=0 if year<2003 | year>2004
gen aceh_treat1_05=deaths_pop
replace aceh_treat1_05=0 if year!=2005
gen aceh_treat1_0608=deaths_pop
replace aceh_treat1_0608=0 if year<2006 | year>2008
gen aceh_treat1_0912=deaths_pop
replace aceh_treat1_0912=0 if year<2009


* Set data to missing that have problematic economic growth data

replace log_gr_tertiary=. if region=="Subulussalam" & (year==2003 | year==2004 | year==2005 | year==2006)


ols_spatial_HAC log_gr_tertiary  aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608 aceh_treat1_0912  yy* acehonecc1- acehonecc22   , ///
timevar(year) panelvar(region2) lat(latitude) lon(longitude) distcutoff(100) lagcutoff(10)
outreg2 using table2, excel replace




*** Non-lethal violence per pop

use "Article for CMPS (Aceh).dta", clear

tsset

* Generate treatment variables

capture drop    aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608  aceh_treat1_0912 

gen aceh_treat1_0304=nonfatal_pop
replace aceh_treat1_0304=f.nonfatal_pop if year==2004
replace aceh_treat1_0304=f2.nonfatal_pop if year==2003
replace aceh_treat1_0304=0 if year<2003 | year>2004
gen aceh_treat1_05=nonfatal_pop
replace aceh_treat1_05=0 if year!=2005
gen aceh_treat1_0608=nonfatal_pop
replace aceh_treat1_0608=0 if year<2006 | year>2008
gen aceh_treat1_0912=nonfatal_pop
replace aceh_treat1_0912=0 if year<2009

* Set data to missing that have problematic economic growth data

replace log_gr_tertiary=. if region=="Subulussalam" & (year==2003 | year==2004 | year==2005 | year==2006)


ols_spatial_HAC log_gr_tertiary  aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608 aceh_treat1_0912  yy* acehonecc1- acehonecc22   , ///
timevar(year) panelvar(region2) lat(latitude) lon(longitude) distcutoff(100) lagcutoff(10)
outreg2 using table2, excel append



**** Construction sector growth

*** Deaths per pop


use "Article for CMPS (Aceh).dta", clear

tsset


* Generate treatment variables

capture drop    aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608  aceh_treat1_0912 

gen aceh_treat1_0304=deaths_pop
replace aceh_treat1_0304=f.deaths_pop if year==2004
replace aceh_treat1_0304=f2.deaths_pop if year==2003
replace aceh_treat1_0304=0 if year<2003 | year>2004
gen aceh_treat1_05=deaths_pop
replace aceh_treat1_05=0 if year!=2005
gen aceh_treat1_0608=deaths_pop
replace aceh_treat1_0608=0 if year<2006 | year>2008
gen aceh_treat1_0912=deaths_pop
replace aceh_treat1_0912=0 if year<2009


* Set data to missing that have problematic economic growth data

replace log_gr_construction=. if region=="Subulussalam" & (year==2003 | year==2004 | year==2005 | year==2006)


ols_spatial_HAC log_gr_construction  aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608 aceh_treat1_0912  yy* acehonecc1- acehonecc22   , ///
timevar(year) panelvar(region2) lat(latitude) lon(longitude) distcutoff(100) lagcutoff(10)
outreg2 using table2, excel append



*** Non-lethal violence per pop

use "Article for CMPS (Aceh).dta", clear


tsset

* Generate treatment variables

capture drop    aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608  aceh_treat1_0912 

gen aceh_treat1_0304=nonfatal_pop
replace aceh_treat1_0304=f.nonfatal_pop if year==2004
replace aceh_treat1_0304=f2.nonfatal_pop if year==2003
replace aceh_treat1_0304=0 if year<2003 | year>2004
gen aceh_treat1_05=nonfatal_pop
replace aceh_treat1_05=0 if year!=2005
gen aceh_treat1_0608=nonfatal_pop
replace aceh_treat1_0608=0 if year<2006 | year>2008
gen aceh_treat1_0912=nonfatal_pop
replace aceh_treat1_0912=0 if year<2009


* Set data to missing that have problematic economic growth data

replace log_gr_construction=. if region=="Subulussalam" & (year==2003 | year==2004 | year==2005 | year==2006)


ols_spatial_HAC log_gr_construction  aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608 aceh_treat1_0912  yy* acehonecc1- acehonecc22   , ///
timevar(year) panelvar(region2) lat(latitude) lon(longitude) distcutoff(100) lagcutoff(10)
outreg2 using table2, excel append




**************************
**** Table 3 - Yearly effect estimates
**************************



*** Deaths per pop

use "Article for CMPS (Aceh).dta", clear

* Generate treatment variables

tsset

capture drop   aceh_treat1_01 aceh_treat1_02 aceh_treat1_03 aceh_treat1_04 aceh_treat1_05 aceh_treat1_06 aceh_treat1_07 aceh_treat1_08 aceh_treat1_09 aceh_treat1_10 aceh_treat1_11 aceh_treat1_12
gen aceh_treat1_01=f4.deaths_pop
replace aceh_treat1_01=0 if year!=2001
gen aceh_treat1_02=f3.deaths_pop
replace aceh_treat1_02=0 if year!=2002
gen aceh_treat1_03=f2.deaths_pop
replace aceh_treat1_03=0 if year!=2003
gen aceh_treat1_04=f.deaths_pop
replace aceh_treat1_04=0 if year!=2004
gen aceh_treat1_05=deaths_pop
replace aceh_treat1_05=0 if year!=2005
gen aceh_treat1_06=deaths_pop
replace aceh_treat1_06=0 if year!=2006
gen aceh_treat1_07=deaths_pop
replace aceh_treat1_07=0 if year!=2007
gen aceh_treat1_08=deaths_pop
replace aceh_treat1_08=0 if year!=2008
gen aceh_treat1_09=deaths_pop
replace aceh_treat1_09=0 if year!=2009
gen aceh_treat1_10=deaths_pop
replace aceh_treat1_10=0 if year!=2010
gen aceh_treat1_11=deaths_pop
replace aceh_treat1_11=0 if year!=2011
gen aceh_treat1_12=deaths_pop
replace aceh_treat1_12=0 if year!=2012



* Set problematic growth data to missing
replace log_gr=. if region=="Subulussalam" & (year==2003 | year==2004 | year==2005 | year==2006)

ols_spatial_HAC log_gr aceh_treat1_01 aceh_treat1_02  aceh_treat1_03 aceh_treat1_04 aceh_treat1_05 aceh_treat1_06 aceh_treat1_07 aceh_treat1_08 aceh_treat1_09 aceh_treat1_10 aceh_treat1_11 aceh_treat1_12  yy* acehonecc1- acehonecc22   , ///
timevar(year) panelvar(region2) lat(latitude) lon(longitude) distcutoff(100) lagcutoff(10)
outreg2 using table3, excel replace





*** Non-lethal violence per pop

use "Article for CMPS (Aceh).dta", clear

* Generate treatment variables

tsset

capture drop   aceh_treat1_01 aceh_treat1_02 aceh_treat1_03 aceh_treat1_04 aceh_treat1_05 aceh_treat1_06 aceh_treat1_07 aceh_treat1_08 aceh_treat1_09 aceh_treat1_10 aceh_treat1_11 aceh_treat1_12
gen aceh_treat1_01=f4.nonfatal_pop
replace aceh_treat1_01=0 if year!=2001
gen aceh_treat1_02=f3.nonfatal_pop
replace aceh_treat1_02=0 if year!=2002
gen aceh_treat1_03=f2.nonfatal_pop
replace aceh_treat1_03=0 if year!=2003
gen aceh_treat1_04=f.nonfatal_pop
replace aceh_treat1_04=0 if year!=2004
gen aceh_treat1_05=nonfatal_pop
replace aceh_treat1_05=0 if year!=2005
gen aceh_treat1_06=nonfatal_pop
replace aceh_treat1_06=0 if year!=2006
gen aceh_treat1_07=nonfatal_pop
replace aceh_treat1_07=0 if year!=2007
gen aceh_treat1_08=nonfatal_pop
replace aceh_treat1_08=0 if year!=2008
gen aceh_treat1_09=nonfatal_pop
replace aceh_treat1_09=0 if year!=2009
gen aceh_treat1_10=nonfatal_pop
replace aceh_treat1_10=0 if year!=2010
gen aceh_treat1_11=nonfatal_pop
replace aceh_treat1_11=0 if year!=2011
gen aceh_treat1_12=nonfatal_pop
replace aceh_treat1_12=0 if year!=2012

* Set problematic growth data to missing
replace log_gr=. if region=="Subulussalam" & (year==2003 | year==2004 | year==2005 | year==2006)

ols_spatial_HAC log_gr  aceh_treat1_01 aceh_treat1_02 aceh_treat1_03 aceh_treat1_04 aceh_treat1_05 aceh_treat1_06 aceh_treat1_07 aceh_treat1_08 aceh_treat1_09 aceh_treat1_10 aceh_treat1_11 aceh_treat1_12  yy* acehonecc1- acehonecc22   , ///
timevar(year) panelvar(region2) lat(latitude) lon(longitude) distcutoff(100) lagcutoff(10)
outreg2 using table3, excel append







**************************
**** Table 4 - GDP p.c. growth
**************************



*** Deaths per pop

use "Article for CMPS (Aceh).dta", clear


tsset

* Generate treatment variables

capture drop    aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608  aceh_treat1_0912 

gen aceh_treat1_0304=deaths_pop
replace aceh_treat1_0304=f.deaths_pop if year==2004
replace aceh_treat1_0304=f2.deaths_pop if year==2003
replace aceh_treat1_0304=0 if year<2003 | year>2004
gen aceh_treat1_05=deaths_pop
replace aceh_treat1_05=0 if year!=2005
gen aceh_treat1_0608=deaths_pop
replace aceh_treat1_0608=0 if year<2006 | year>2008
gen aceh_treat1_0912=deaths_pop
replace aceh_treat1_0912=0 if year<2009



* Set problematic growth data to missing
replace log_cap_gr=. if region=="Subulussalam" & (year==2003 | year==2004 | year==2005 | year==2006)

ols_spatial_HAC log_cap_gr  aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608 aceh_treat1_0912  yy* acehonecc1- acehonecc22   , ///
timevar(year) panelvar(region2) lat(latitude) lon(longitude) distcutoff(100) lagcutoff(10)
outreg2 using table4, excel replace



*** Non-lethal violence per pop

use "Article for CMPS (Aceh).dta", clear



tsset

* Generate treatment variables

capture drop    aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608  aceh_treat1_0912 

gen aceh_treat1_0304=nonfatal_pop
replace aceh_treat1_0304=f.nonfatal_pop if year==2004
replace aceh_treat1_0304=f2.nonfatal_pop if year==2003
replace aceh_treat1_0304=0 if year<2003 | year>2004
gen aceh_treat1_05=nonfatal_pop
replace aceh_treat1_05=0 if year!=2005
gen aceh_treat1_0608=nonfatal_pop
replace aceh_treat1_0608=0 if year<2006 | year>2008
gen aceh_treat1_0912=nonfatal_pop
replace aceh_treat1_0912=0 if year<2009




** Conflict variables 
replace log_cap_gr=. if region=="Subulussalam" & (year==2003 | year==2004 | year==2005 | year==2006)

ols_spatial_HAC log_cap_gr  aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608 aceh_treat1_0912  yy* acehonecc1- acehonecc22   , ///
timevar(year) panelvar(region2) lat(latitude) lon(longitude) distcutoff(100) lagcutoff(10)
outreg2 using table4, excel append




**************************
**** Table 5 - oil and gas revenue included
**************************



*** Deaths per pop

use "Article for CMPS (Aceh).dta", clear


tsset


* Generate treatment variables

capture drop    aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608  aceh_treat1_0912 

gen aceh_treat1_0304=deaths_pop
replace aceh_treat1_0304=f.deaths_pop if year==2004
replace aceh_treat1_0304=f2.deaths_pop if year==2003
replace aceh_treat1_0304=0 if year<2003 | year>2004
gen aceh_treat1_05=deaths_pop
replace aceh_treat1_05=0 if year!=2005
gen aceh_treat1_0608=deaths_pop
replace aceh_treat1_0608=0 if year<2006 | year>2008
gen aceh_treat1_0912=deaths_pop
replace aceh_treat1_0912=0 if year<2009




* Set problematic growth data to missing
replace log_gr_oil=. if region=="Subulussalam" & (year==2003 | year==2004 | year==2005 | year==2006)



ols_spatial_HAC log_gr_oil  aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608 aceh_treat1_0912  yy* acehonecc1- acehonecc22   , ///
timevar(year) panelvar(region2) lat(latitude) lon(longitude) distcutoff(100) lagcutoff(10)
outreg2 using table5, excel replace





*** Non-lethal violence per pop

use "Article for CMPS (Aceh).dta", clear



tsset

* Generate treatment variables

capture drop    aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608  aceh_treat1_0912 

gen aceh_treat1_0304=nonfatal_pop
replace aceh_treat1_0304=f.nonfatal_pop if year==2004
replace aceh_treat1_0304=f2.nonfatal_pop if year==2003
replace aceh_treat1_0304=0 if year<2003 | year>2004
gen aceh_treat1_05=nonfatal_pop
replace aceh_treat1_05=0 if year!=2005
gen aceh_treat1_0608=nonfatal_pop
replace aceh_treat1_0608=0 if year<2006 | year>2008
gen aceh_treat1_0912=nonfatal_pop
replace aceh_treat1_0912=0 if year<2009



* Set problematic growth data to missing
replace log_gr_oil=. if region=="Subulussalam" & (year==2003 | year==2004 | year==2005 | year==2006)


ols_spatial_HAC log_gr_oil  aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608 aceh_treat1_0912  yy* acehonecc1- acehonecc22   , ///
timevar(year) panelvar(region2) lat(latitude) lon(longitude) distcutoff(100) lagcutoff(10)
outreg2 using table5, excel append







**************************
**** Table 6 - Rural areas only 
**************************

use "Article for CMPS (Aceh).dta", clear


*** Only Kabupatens
capture drop  kabcc*
quietly tab region if district_type=="Kab", gen(kabcc) 


tsset


* Generate treatment variables

capture drop    aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608  aceh_treat1_0912 

gen aceh_treat1_0304=deaths_pop
replace aceh_treat1_0304=f.deaths_pop if year==2004
replace aceh_treat1_0304=f2.deaths_pop if year==2003
replace aceh_treat1_0304=0 if year<2003 | year>2004
gen aceh_treat1_05=deaths_pop
replace aceh_treat1_05=0 if year!=2005
gen aceh_treat1_0608=deaths_pop
replace aceh_treat1_0608=0 if year<2006 | year>2008
gen aceh_treat1_0912=deaths_pop
replace aceh_treat1_0912=0 if year<2009




* Set problematic growth data to missing

replace log_gr=. if region=="Subulussalam" & (year==2003 | year==2004 | year==2005 | year==2006)

ols_spatial_HAC log_gr  aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608 aceh_treat1_0912  yy* kabcc2- kabcc18    if district_type=="Kab", ///
timevar(year) panelvar(region2) lat(latitude) lon(longitude) distcutoff(100) lagcutoff(10)
outreg2 using table6, excel replace



*** Non-lethal violence per pop

use "Article for CMPS (Aceh).dta", clear


*** Only Kabupatens
capture drop  kabcc*
quietly tab region if district_type=="Kab", gen(kabcc) 



tsset

* Generate treatment variables

capture drop    aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608  aceh_treat1_0912 

gen aceh_treat1_0304=nonfatal_pop
replace aceh_treat1_0304=f.nonfatal_pop if year==2004
replace aceh_treat1_0304=f2.nonfatal_pop if year==2003
replace aceh_treat1_0304=0 if year<2003 | year>2004
gen aceh_treat1_05=nonfatal_pop
replace aceh_treat1_05=0 if year!=2005
gen aceh_treat1_0608=nonfatal_pop
replace aceh_treat1_0608=0 if year<2006 | year>2008
gen aceh_treat1_0912=nonfatal_pop
replace aceh_treat1_0912=0 if year<2009





* Set problematic growth data to missing

replace log_gr=. if region=="Subulussalam" & (year==2003 | year==2004 | year==2005 | year==2006)

ols_spatial_HAC log_gr  aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608 aceh_treat1_0912  yy* kabcc2- kabcc18    if district_type=="Kab", ///
timevar(year) panelvar(region2) lat(latitude) lon(longitude) distcutoff(100) lagcutoff(10)
outreg2 using table6, excel append






**************************
**** Table 7 - including spatial-x variables
**************************



*** Deaths per pop

use "Article for CMPS (Aceh).dta", clear


tsset


* Generate treatment variables

capture drop    aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608  aceh_treat1_0912 

gen aceh_treat1_0304=deaths_pop
replace aceh_treat1_0304=f.deaths_pop if year==2004
replace aceh_treat1_0304=f2.deaths_pop if year==2003
replace aceh_treat1_0304=0 if year<2003 | year>2004
gen aceh_treat1_05=deaths_pop
replace aceh_treat1_05=0 if year!=2005
gen aceh_treat1_0608=deaths_pop
replace aceh_treat1_0608=0 if year<2006 | year>2008
gen aceh_treat1_0912=deaths_pop
replace aceh_treat1_0912=0 if year<2009


* Set problematic growth data to missing
replace log_gr=. if region=="Subulussalam" & (year==2003 | year==2004 | year==2005 | year==2006)

ols_spatial_HAC log_gr  aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608 aceh_treat1_0912  deaths_cont_rowst_0304 deaths_cont_rowst_05 deaths_cont_rowst_0608 deaths_cont_rowst_0912 yy* acehonecc1- acehonecc22   , ///
timevar(year) panelvar(region2) lat(latitude) lon(longitude) distcutoff(100) lagcutoff(10)
outreg2 using table7, excel replace




*** Non-lethal violence per pop

use "Article for CMPS (Aceh).dta", clear

tsset

* Generate treatment variables

capture drop    aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608  aceh_treat1_0912 

gen aceh_treat1_0304=nonfatal_pop
replace aceh_treat1_0304=f.nonfatal_pop if year==2004
replace aceh_treat1_0304=f2.nonfatal_pop if year==2003
replace aceh_treat1_0304=0 if year<2003 | year>2004
gen aceh_treat1_05=nonfatal_pop
replace aceh_treat1_05=0 if year!=2005
gen aceh_treat1_0608=nonfatal_pop
replace aceh_treat1_0608=0 if year<2006 | year>2008
gen aceh_treat1_0912=nonfatal_pop
replace aceh_treat1_0912=0 if year<2009



* Set problematic growth data to missing
replace log_gr=. if region=="Subulussalam" & (year==2003 | year==2004 | year==2005 | year==2006)

ols_spatial_HAC log_gr  aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608 aceh_treat1_0912 incidents_cont_rowst_0304 incidents_cont_rowst_05 incidents_cont_rowst_0608 incidents_cont_rowst_0912 yy* acehonecc1- acehonecc22   , ///
timevar(year) panelvar(region2) lat(latitude) lon(longitude) distcutoff(100) lagcutoff(10)
outreg2 using table7, excel append






**************************
**** Table 8 - Including tsunami death rate & aid disbursement
**************************

*** Deaths per pop

use "Article for CMPS (Aceh).dta", clear


tsset

* Generate treatment variables

capture drop    aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608  aceh_treat1_0912 

gen aceh_treat1_0304=deaths_pop
replace aceh_treat1_0304=f.deaths_pop if year==2004
replace aceh_treat1_0304=f2.deaths_pop if year==2003
replace aceh_treat1_0304=0 if year<2003 | year>2004
gen aceh_treat1_05=deaths_pop
replace aceh_treat1_05=0 if year!=2005
gen aceh_treat1_0608=deaths_pop
replace aceh_treat1_0608=0 if year<2006 | year>2008
gen aceh_treat1_0912=deaths_pop
replace aceh_treat1_0912=0 if year<2009


capture drop   tsunami_killed_pc_lead0304 tsunami_killed_pc_treat_05 tsunami_killed_pc_treat_0608 tsunami_killed_pc_treat_0912
gen tsunami_killed_pc_lead0304=tsunami_killed_pc
replace tsunami_killed_pc_lead0304=0 if year<2003 | year>2004
gen tsunami_killed_pc_treat_05=tsunami_killed_pc
replace tsunami_killed_pc_treat_05=0 if year!=2005
gen tsunami_killed_pc_treat_0608=tsunami_killed_pc
replace tsunami_killed_pc_treat_0608=0 if year<2006 | year>2008
gen tsunami_killed_pc_treat_0912=tsunami_killed_pc
replace tsunami_killed_pc_treat_0912=0 if year<2009



capture drop    aid_treat1_0304 aid_treat1_05 aid_treat1_0608 aid_treat1_0912 
gen aid_treat1_0304=aid_dis_pop
replace aid_treat1_0304=f.aid_dis_pop if year==2004
replace aid_treat1_0304=f2.aid_dis_pop if year==2003
replace aid_treat1_0304=f3.aid_dis_pop if year==2002
replace aid_treat1_0304=0 if year<2002 | year>2004
gen aid_treat1_05=aid_dis_pop
replace aid_treat1_05=0 if year!=2005
gen aid_treat1_0608=aid_dis_pop
replace aid_treat1_0608=0 if year<2006 | year>2008
gen aid_treat1_0912=aid_dis_pop
replace aid_treat1_0912=0 if year<2009


* Set problematic growth data to missing

replace log_gr=. if region=="Subulussalam" & (year==2003 | year==2004 | year==2005 | year==2006)

ols_spatial_HAC log_gr  aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608 aceh_treat1_0912 tsunami_killed_pc_lead0304 tsunami_killed_pc_treat_05 tsunami_killed_pc_treat_0608 tsunami_killed_pc_treat_0912   aid_treat1_0304 aid_treat1_05 aid_treat1_0608 aid_treat1_0912  yy* acehonecc1- acehonecc22   , ///
timevar(year) panelvar(region2) lat(latitude) lon(longitude) distcutoff(100) lagcutoff(10)
outreg2 using table8, excel replace




** Interaction effects
reg log_gr  aceh_treat1_0304  c.aceh_treat1_05##c.tsunami_killed_pc_treat_05 c.aceh_treat1_0608##c.tsunami_killed_pc_treat_0608 c.aceh_treat1_0912##c.tsunami_killed_pc_treat_0912 yy* acehonecc1- acehonecc22   , ///
cluster(id)


reg log_gr  aceh_treat1_0304  c.aceh_treat1_05##c.aid_treat1_05 c.aceh_treat1_0608##c.aid_treat1_0608 c.aceh_treat1_0912##c.aid_treat1_0912 yy* acehonecc1- acehonecc22   , ///
cluster(id)



*** Non-lethal violence per pop

use "Article for CMPS (Aceh).dta", clear



tsset

* Generate treatment variables

capture drop    aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608  aceh_treat1_0912 

gen aceh_treat1_0304=nonfatal_pop
replace aceh_treat1_0304=f.nonfatal_pop if year==2004
replace aceh_treat1_0304=f2.nonfatal_pop if year==2003
replace aceh_treat1_0304=0 if year<2003 | year>2004
gen aceh_treat1_05=nonfatal_pop
replace aceh_treat1_05=0 if year!=2005
gen aceh_treat1_0608=nonfatal_pop
replace aceh_treat1_0608=0 if year<2006 | year>2008
gen aceh_treat1_0912=nonfatal_pop
replace aceh_treat1_0912=0 if year<2009



capture drop   tsunami_killed_pc_lead0304 tsunami_killed_pc_treat_05 tsunami_killed_pc_treat_0608 tsunami_killed_pc_treat_0912
gen tsunami_killed_pc_lead0304=tsunami_killed_pc
replace tsunami_killed_pc_lead0304=0 if year<2003 | year>2004
gen tsunami_killed_pc_treat_05=tsunami_killed_pc
replace tsunami_killed_pc_treat_05=0 if year!=2005
gen tsunami_killed_pc_treat_0608=tsunami_killed_pc
replace tsunami_killed_pc_treat_0608=0 if year<2006 | year>2008
gen tsunami_killed_pc_treat_0912=tsunami_killed_pc
replace tsunami_killed_pc_treat_0912=0 if year<2009


capture drop    aid_treat1_0304 aid_treat1_05 aid_treat1_0608 aid_treat1_0912 
gen aid_treat1_0304=aid_dis_pop
replace aid_treat1_0304=f.aid_dis_pop if year==2004
replace aid_treat1_0304=f2.aid_dis_pop if year==2003
replace aid_treat1_0304=f3.aid_dis_pop if year==2002
replace aid_treat1_0304=0 if year<2002 | year>2004
gen aid_treat1_05=aid_dis_pop
replace aid_treat1_05=0 if year!=2005
gen aid_treat1_0608=aid_dis_pop
replace aid_treat1_0608=0 if year<2006 | year>2008
gen aid_treat1_0912=aid_dis_pop
replace aid_treat1_0912=0 if year<2009





* Set problematic growth data to missing

replace log_gr=. if region=="Subulussalam" & (year==2003 | year==2004 | year==2005 | year==2006)

ols_spatial_HAC log_gr  aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608 aceh_treat1_0912 tsunami_killed_pc_lead0304 tsunami_killed_pc_treat_05 tsunami_killed_pc_treat_0608 tsunami_killed_pc_treat_0912  aid_treat1_0304 aid_treat1_05 aid_treat1_0608 aid_treat1_0912  yy* acehonecc1- acehonecc22   , ///
timevar(year) panelvar(region2) lat(latitude) lon(longitude) distcutoff(100) lagcutoff(10)
outreg2 using table8, excel append




** Interaction effects
reg log_gr  aceh_treat1_0304  c.aceh_treat1_05##c.tsunami_killed_pc_treat_05 c.aceh_treat1_0608##c.tsunami_killed_pc_treat_0608 c.aceh_treat1_0912##c.tsunami_killed_pc_treat_0912 yy* acehonecc1- acehonecc22   , ///
cluster(id)


reg log_gr  aceh_treat1_0304  c.aceh_treat1_05##c.aid_treat1_05 c.aceh_treat1_0608##c.aid_treat1_0608 c.aceh_treat1_0912##c.aid_treat1_0912 yy* acehonecc1- acehonecc22   , ///
cluster(id)




**************************
**** Non-reported robustness test: UCDP battle deaths data
**************************



*** Deaths per pop

use "Article for CMPS (Aceh).dta", clear

tsset


corr deaths_pop UCDP_best_est_fatal_pc UCDP_high_est_fatal_pc UCDP_low_est_fatal_pc


* Generate treatment variables - UNCDP best estimate

tsset

capture drop    aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608  aceh_treat1_0912 

gen aceh_treat1_0304=UCDP_best_est_fatal_pc
replace aceh_treat1_0304=f.UCDP_best_est_fatal_pc if year==2004
replace aceh_treat1_0304=f2.UCDP_best_est_fatal_pc if year==2003
replace aceh_treat1_0304=0 if year<2003 | year>2004
gen aceh_treat1_05=UCDP_best_est_fatal_pc
replace aceh_treat1_05=0 if year!=2005
gen aceh_treat1_0608=UCDP_best_est_fatal_pc
replace aceh_treat1_0608=0 if year<2006 | year>2008
gen aceh_treat1_0912=UCDP_best_est_fatal_pc
replace aceh_treat1_0912=0 if year<2009

* Set problematic growth data to missing

replace log_gr=. if region=="Subulussalam" & (year==2003 | year==2004 | year==2005 | year==2006)


ols_spatial_HAC log_gr  aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608 aceh_treat1_0912  yy* acehonecc1- acehonecc22   , ///
timevar(year) panelvar(region2) lat(latitude) lon(longitude) distcutoff(100) lagcutoff(10)


* Generate treatment variables - UNCDP high estimate

tsset

capture drop    aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608  aceh_treat1_0912 

gen aceh_treat1_0304=UCDP_high_est_fatal_pc
replace aceh_treat1_0304=f.UCDP_high_est_fatal_pc if year==2004
replace aceh_treat1_0304=f2.UCDP_high_est_fatal_pc if year==2003
replace aceh_treat1_0304=0 if year<2003 | year>2004
gen aceh_treat1_05=UCDP_high_est_fatal_pc
replace aceh_treat1_05=0 if year!=2005
gen aceh_treat1_0608=UCDP_high_est_fatal_pc
replace aceh_treat1_0608=0 if year<2006 | year>2008
gen aceh_treat1_0912=UCDP_high_est_fatal_pc
replace aceh_treat1_0912=0 if year<2009

* Set problematic growth data to missing

replace log_gr=. if region=="Subulussalam" & (year==2003 | year==2004 | year==2005 | year==2006)


ols_spatial_HAC log_gr  aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608 aceh_treat1_0912  yy* acehonecc1- acehonecc22   , ///
timevar(year) panelvar(region2) lat(latitude) lon(longitude) distcutoff(100) lagcutoff(10)


* Generate treatment variables - UNCDP low estimate

tsset

capture drop    aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608  aceh_treat1_0912 

gen aceh_treat1_0304=UCDP_low_est_fatal_pc
replace aceh_treat1_0304=f.UCDP_low_est_fatal_pc if year==2004
replace aceh_treat1_0304=f2.UCDP_low_est_fatal_pc if year==2003
replace aceh_treat1_0304=0 if year<2003 | year>2004
gen aceh_treat1_05=UCDP_low_est_fatal_pc
replace aceh_treat1_05=0 if year!=2005
gen aceh_treat1_0608=UCDP_low_est_fatal_pc
replace aceh_treat1_0608=0 if year<2006 | year>2008
gen aceh_treat1_0912=UCDP_low_est_fatal_pc
replace aceh_treat1_0912=0 if year<2009

* Set problematic growth data to missing

replace log_gr=. if region=="Subulussalam" & (year==2003 | year==2004 | year==2005 | year==2006)


ols_spatial_HAC log_gr  aceh_treat1_0304 aceh_treat1_05 aceh_treat1_0608 aceh_treat1_0912  yy* acehonecc1- acehonecc22   , ///
timevar(year) panelvar(region2) lat(latitude) lon(longitude) distcutoff(100) lagcutoff(10)


